﻿using System;
using System.Collections.Generic;
using System.Text;
using WindowsLive.Writer.Api;

namespace Writerous
{
    public class PluginSettings
    {
        private const string EMAILADDRESS = "EMAILADDRESS";
        private const string PASSWORD = "PASSWORD";
        private const string SITEID = "SITEID";
        private const string SITENAME = "SITENAME";
        private const string AUTOPOST = "AUTOPOST";
        private const string POSTTOBLOG = "POSTTOBLOG";
        private IProperties m_properties;

        public PluginSettings(IProperties properties)
        {
            m_properties = properties;
        }

        public string EmailAddress
        {
            get { return PC1.DecryptString(m_properties.GetString(EMAILADDRESS, "")); }
            set { m_properties.SetString(EMAILADDRESS, PC1.EncryptString(value)); }
        }

        public string Password
        {
            get { return PC1.DecryptString(m_properties.GetString(PASSWORD, "")); }
            set { m_properties.SetString(PASSWORD, PC1.EncryptString(value)); }
        }

        public int SiteId
        {
            get { return m_properties.GetInt(SITEID, -1); }
            set { m_properties.SetInt(SITEID, value); }
        }

        public string SiteName
        {
            get { return m_properties.GetString(SITENAME, ""); }
            set { m_properties.SetString(SITENAME, value); }
        }

        public bool AutoPost
        {
            get { return m_properties.GetBoolean(AUTOPOST, false); }
            set { m_properties.SetBoolean(AUTOPOST, value); }
        }

        public bool PostToBlog
        {
            get { return m_properties.GetBoolean(POSTTOBLOG, false); }
            set { m_properties.SetBoolean(POSTTOBLOG, value); }
        }
    }
}
